﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Snipr.CoreLib.DataAccess;

namespace Snipr.AppLogic
{
    public class AppUser
    {
        public AppUser(int userID)
        {
            UserID = userID;
        }
        public AppUser(string userName)
        {
            UserName = userName;
            UserID = GetUserID(userName);
        }

        public int UserID { get; set; }
        public string UserName { get; set; }

        public int GetUserID(string userName = null)
        {
            userName = userName ?? UserName;
            User user = new User();
            if (user.GetUserID(userName).FirstOrDefault().Value != null)
                UserID = (int)user.GetUserID(userName).FirstOrDefault().Value;
            else
                UserID = -1;
            return UserID;
        }
        public string GetUserName(int userID = 0)
        {
            userID = (userID != 0) ? userID : UserID;
            User user = new User();
            if (user.GetUserName(userID).FirstOrDefault().Value != null)
                UserName = (string)user.GetUserName(userID).FirstOrDefault().Value;
            else
                UserName = null;
            return UserName;
        }
    }
}
